package 哈希表;

import java.util.*;

public class Demo08 {
    public static void main(String[] args) {
        Map<String,List<String>> map = new HashMap<>();
        Set<String> set = map.keySet();
        for(String s:set){
            map.get(s);
        }
        String str = "aaa";
        char[] chars = str.toCharArray();
        Arrays.sort(chars);
        String s = Arrays.toString(chars);
    }
    static class Solution {
        public List<List<String>> groupAnagrams(String[] nums) {
            List<List<String>> newlist = new LinkedList<>();
            Map<String,List<String>> map = new HashMap<>();
            for (String num : nums) {
                String str = sort(num);
                System.out.println(str);
                List<String> list;
                if (map.containsKey(str)) {
                    list = map.get(str);
                } else {
                    list = new LinkedList<>();
                }
                list.add(num);
                map.put(str, list);
            }

            Set<String> set = map.keySet();
            for(String s:set){
                newlist.add(map.get(s));
            }
            return newlist;
        }

        public String sort(String str){
            char[] chars = str.toCharArray();
            Arrays.sort(chars);
            return Arrays.toString(chars);
        }
    }
}
